<template>
  <page-container>
    <search-form
      v-model="searchForm"
      :searchColumns="searchColumns"
      :searchOptions="{ menuSpan: 4 }"
      @on-search="handleSearch">
    </search-form>

    <avue-table
      :dataList="dataList"
      :loading="loading"
      :page="page"
      :tableColumns="tableColumns"
      @onPageChange="onPageChange">
    </avue-table>
  </page-container>
</template>

<script>
import tableMixins from '@/mixins/table'
import { deepClone } from '@/utils'
import { mapGetters } from 'vuex'
import { getUnlockList } from '@/api/userManage'
import { searchColumns, tableColumns } from './config/table-config'

export default {
  mixins: [tableMixins],
  data() {
    return {
      dataList: [],
      childList: [],
      orderStatus: [
        { value: 1, label: '待付款' },
        { value: 2, label: '已关闭' },
        { value: 3, label: '已完成' },
      ],
      searchForm: {
        dateRange: [this.$startStamp(new Date()), this.$endStamp(new Date())],
      },
      editForm: {},
    }
  },
  computed: {
    ...mapGetters(['commonData', 'countryList']),
    userList() {
      return this.commonData?.userList ?? []
    },
    searchColumns,
    tableColumns,
  },
  methods: {
    fetchMethod: getUnlockList,

    // 查询参数格式化
    formatSearch() {
      const searchParams = deepClone(this.searchForm)
      const [start, end] = this.searchForm.dateRange
      searchParams.start = start && this.$dayjs(this.$startStamp(start)).unix()
      searchParams.end = end && this.$dayjs(this.$endStamp(end)).unix()
      delete searchParams.dateRange
      return searchParams
    },
  },
  mounted() {
    this.handleSearch()
  },
}
</script>

<style lang="scss" scoped></style>
